<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title></title>

    <style>

    </style>
    <script src="vue.min.js"></script>
</head>
<body>
<div id=app>
    {{a}}
    <button v-on:click="change">更新</button>
    <button @click="destory">销毁</button>
</div>
<script>
    var myVue = new Vue({
        el: "#app",
        data: {
            a: "Vue.js"
        },
        methods: {
            change: function(){
                this.a = "Update Vue"
            },
            destory: function(){
                myVue.$destroy();
                this.a = "Destroy Vue"
            }
        },
        beforeCreate: function() {
            console.log("创建前");
            console.log(this.a);
            console.log(this.$el)
        },
        created: function() {
            console.log("创建之后");
            console.log(this.a);
            console.log(this.$el)
        },
        beforeMount: function() {
            console.log("mount之前");
            console.log(this.a);
            console.log(this.$el)
        },
        mounted: function() {
            console.log("mount之后");
            console.log(this.a);
            console.log(this.$el)
        },
        beforeUpdate: function() {
            console.log("更新前");
            console.log(this.a);
            console.log(this.$el)
        },
        updated: function() {
            console.log("更新完成");
            console.log(this.a);
            console.log(this.$el)
        },
        beforeDestroy: function() {
            console.log("销毁前");
            console.log(this.a);
            console.log(this.$el);
        },
        destroyed: function() {
            console.log("已销毁");
            setTimeout(function(){
                console.log(this.a);
                console.log(this.$el)
            },1);
        }
    });
</script>
</body>
</html>



















